<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        //     ## 1. 斐波那契数列
        // ```javascript
        //     1 1 2 3 5 8 13 21.......
        //     推导公式：fib(m) = fib(m-1) + fib(m-2)
        // ```

        function fn(num){
            if(num > 0 && num % 1 ===0){
                if(num === 1 || num === 2){
                        return 1
                    }

                    return fn(num - 1 ) + fn(num - 2)
            }else{
                alert('请输入一个正整数')
            }
        }

        var res = fn(prompt('请输入一个正整数')-0)
        alert(res)
    </script>
</body>
</html>